package exam.test15;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2020-12-12
 * Time: 10:33
 */
public class TownStatistics  implements Comparable<TownStatistics> {
    private int accidents;
    private int fatalities;
    private String name;

    public TownStatistics(String name) {
        this.name = name;
        accidents = fatalities = 0;
    }

    public void incrementAccidents() {
        accidents++;
    }

    public void incrementFatalities() {
        fatalities++;
    }

    public int getAccidents() {
        return accidents;
    }

    public int getFatalities() {
        return fatalities;
    }

    public String getName() {
        return name;
    }

    public String toString() {
        return name + ": accidents=" + accidents + ", fatalities=" + fatalities;
    }

    public int compareTo(TownStatistics other) {
        return name.compareTo(other.name);
    }
}
